package com.hschinese.pronunciation.utils;

import android.content.Context;
import android.view.GestureDetector;
import android.view.MotionEvent;

import com.hschinese.pronunciation.interfaces.RefreshPageInterface;

/**
 * Created by wo on 2015/11/4.
 */
public class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
    private Context mContext;
    private RefreshPageInterface mListener = null;
    public MyGestureListener(Context context, RefreshPageInterface listener) {
        mContext = context;
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onSingleTapUp.");
        return false;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onLongPress.");
        super.onLongPress(e);
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        Logger.i("xionghy - MyGestureListener - onScroll.");
        return false;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onShowPress.");
        super.onShowPress(e);
    }

    @Override
    public boolean onDown(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onDown.");
        return false;
    }



    @Override
    public boolean onDoubleTap(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onDoubleTap.");
        return false;
    }

    @Override
    public boolean onDoubleTapEvent(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onDoubleTapEvent.");
        return false;
    }

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
        Logger.i("xionghy - MyGestureListener - onSingleTapConfirmed.");
        return false;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        Logger.i("xionghy - MyGestureListener - onFling.");
        if (mListener != null) {
            mListener.refresh();
            return true;
        } else
            return super.onFling(e1, e2, velocityX, velocityY);
    }
}
